<template>
  <div>
    <div class="background">
      <!-- <div class="back" @click='back'>
        <i>
          < </i>
            <span>返回</span>
      </div> -->
      <div class="btnbg">
        <ul>
          <li class="inputStyle">
            <p>账号:</p>
            <input type="text" v-model='phone' autocomplete="off" @focus="xianshi">
          </li>
          <li class="xishi">{{yzUser}}</li>
          <li class="inputStyle">
            <p>密码:</p>
            <input type="password" v-model='password' autocomplete="new-password" @focus="xianshi">
          </li>
          <li class="xishi2">{{mima}}</li>
        </ul>
        <div class='resiger' style='cursor:pointer'>
          <span @click='$router.push({path:"/forget"})'>忘记密码</span>
          <span @click='$router.push({path:"/register"})'>点击注册</span>
        </div>
        <div class="login">
          <p @click='login'>登录</p>
        </div>
        <div class="logintishi">
          {{loginIf}}
        </div>
        <div class="instructions">
        <h4>游戏简介说明:</h4>
        <p>布勒游戏为布勒旗下一款区块链游戏，游戏内容为布勒挖参和布勒炼丹两种。</p>
      </div>
      </div>
    </div>
  </div>
</template>

<script>
import $ from "jquery";

export default {
  data() {
    return {
      phone: "",
      password: "",
      yzUser: "",
      mima: "",
      loginIf: "",
    };
  },

  created() {
    // u.usreALL(data=>{
    //   console.log(data)
    // })
  },
  mounted() {
    this.$parent.flag1 = false;
    this.$parent.flag2 = false;
  },
  methods: {
    xianshi() {
      this.yzUser = ''
      this.mima = ''
      this.loginIf = ''
    },
    login() {
      var that = this;
      if($.trim(this.phone)=='' && $.trim(this.password)==''){
         this.yzUser = "请输入用户名"
         this.mima = "请输入密码"
        return
      }
      if($.trim(this.phone)==''){
         this.yzUser = "请输入用户名"
        return
      }
      if($.trim(this.password)==''){
        this.mima = "请输入密码"
        return
      }
      u.login({ username: this.phone, password: this.password }, data => {
        if (data[0].code == 200) {
          u.setStore("user", {
            name: this.phone,
            userid: this.phone,
            password: this.password
          });
          u.setStore("userInfo", data[0].user);
          that.$router.push({ path: "/choosePage" });
        } else if (data[0].code == 404) {
          // this.$parent.loading({
          //   message: "该账号不存在",
          //   type: false
          // });
          this.yzUser = "该账号不存在"
        } else if (data[0].code == 500) {
          // this.$parent.loading({
          //   message: "密码错误",
          //   type: false
          // });
          this.mima = "密码错误"
        } else {
          // this.$parent.loading({
          //   message: "登录失败",
          //   type: false
          // });
          this.loginIf = "登录失败"
        }
      });
    },
    //返回上一页
    back() {
      history.back();
    }
  }
};
</script>

<style lang='less' scoped>
.resiger {
  display: flex;
  justify-content: space-between;
  padding-right: 50px;
  padding-left: 30px;
  position: relative;
  top: -45px;
}
.background .back {
  width: 99px;
  height: 38px;
  display: flex;
  flex-direction: row;
  background: url("../../static/image/Highlight.png") no-repeat;
  background-size: 100% 100%;
  position: absolute;
  right: 28%;
  top: 4%;
  justify-content: center;
  line-height: 34px;
  cursor: pointer;
  i {
    margin-right: 10px;
    font-size: 16px;
    color: #ffffff;
    text-shadow: -3px 0px 1px #9f6946, 2px 0px 2px #9f6946;
  }
  span {
    font-size: 16px;
    color: #ffffff;
    font-weight: bold;
    text-shadow: -3px 0px 1px #9f6946, 2px 0px 2px #9f6946;
  }
}
.background {
  width: 100vw;
  height: 100vh;
  background: url("../../static/image/bg.png") no-repeat;
  position: relative;
  background-size: 100% 100%;
  .btnbg {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 632px;
    height: 428px;
    background: url("../../static/image/btnBg.png") no-repeat;
    ul {
      padding: 25px 0 0 20px;
      p {
        text-shadow: 0 2.5px #3a230a, 2px 0 #3a230a, -2px 0 #3a230a,
          0 -2px #3a230a;
        font-size: 24px;
        font-weight: bold;
      }
      .inputStyle {
        display: flex;
        align-items: center;
        background: url("../../static/image/btnLong.png") no-repeat;
        height: 76px;
        padding-left: 25px;
        color: #ffffff;
        font-size: 24px;
        input {
          background-color: transparent;
          line-height: normal;
          outline: 0;
          border: none;
          color: #ffffff;
          font-weight: bold;
          font-size: 24px;
          text-shadow: 0 2px #9e5d1e, 2px 0 #9e5d1e, -2px 0 #9e5d1e,
            0 -2px #9e5d1e;
          margin: 5px 0 0 25px;
         
        }
      }
      .xishi{
        height: 50px;
        padding-left: 39%;
        color: white;
        font-weight: bold;
        line-height: 36px;
        text-shadow: 0 1px red, 1px 0 red, -1px 0 red,
        
      }
      .xishi2{
        padding-top: 25px;
        height: 50px;
        padding-left: 39%;
        color: white;
        font-weight: bold;
        line-height: 0px;
       text-shadow: 0 1px red, 1px 0 red, -1px 0 red,
      }
    }
    .login {
      width: 238px;
      height: 84px;
      background: url("../../static/image/btnYellow.png") no-repeat;
      position: absolute;
      left: 50%;
      top: 75%;
      transform: translate(-50%, -50%);
      cursor: pointer;
      p {
        text-align: center;
        line-height: 84px;
        font-size: 26px;
        letter-spacing: 3px;
        font-weight: bold;
        color: #ffffff;
        font-size: 26px;
        text-shadow: 0 2.5px #a65d08, 2px 0 #a65d08, -2px 0 #a65d08,
          0 -2px #a65d08;
      }
    }
    .logintishi{
       position: absolute;
        left: 41%;
        top: 87%;
        color: #ffffff;
        font-size: 30px;
         text-shadow: 0 2.5px red, 2px 0 red, -2px 0 red,
          0 -2px red;
    }
  }
  .instructions{
    width: 632px;
    height: 60px;
    position: absolute;
    left: 50%;
    bottom: -22%;
    transform: translate(-50%, -50%);
    color: #805200;
    h4{
      font-size: 18px;
      line-height: 42px;
    }
    p{
      font-size: 16px;
    }
  }
}
</style>
